<template>
  <el-card>
    <div slot="header">
      <el-button @click="$router.push({
        name: 'advert-space-create'
      })">添加广告位</el-button>
    </div>
    <el-table
    :data="datas">
      <el-table-column
        prop="spaceKey"
        label="spaceKey">
      </el-table-column>
      <el-table-column
        prop="name"
        label="广告位名称">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间">
      </el-table-column>
      <el-table-column
        prop="updateTime"
        label="更新时间">
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button
          @click="$router.push({
            name: 'advert-space-edit',
            params: {
              spaceId: scope.row.id
            }
          })">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
import { getAllAdvertSpace } from '@/services/advert-space'

export default {
  data () {
    return {
      datas: []
    }
  },
  created () {
    this.getAllList()
  },
  methods: {
    async getAllList () {
      const { data } = await getAllAdvertSpace()
      if (data.state === 1) {
        this.datas = data.content
      }
    }
  }
}
</script>

<style lang='scss' scoped></style>
